<?php
class  Test extends IController{
    public  function  demo(){
        $name="老大";
        $age="18";
        $this->name=$name;
        $this->setRenderData(['xixixi'=>$age]);
        $this->redirect("demo");
    }
    public function add_do(){
        $name=IReq::get("name");
        $pwd=IFilter::act(IReq::get('pwd'),'int');
        $model=new IModel("user");
        $arr=array('name'=>$name,'pwd'=>$pwd);
        $model->setData($arr);
        $res=$model->add();
        if($res){
            $this->redirect("show");
        }
    }
    public function show(){
        $model=new IModel();
        $res=$model->query();
        $this->setRenderData(['res'=>$res]);
        $this->redirect("show");
    }
    public function upd(){
        $id=IReq::get('id');
        $model=new IModel();
        $res=$model->query("id=$id");
        $this->setRenderData(['res'=>$res]);
        $this->redirect("upd");
    }
    public function upd_do(){
        $name=IReq::get("name");
        $id=IFilter::act(IReq::get("id"),'int');
        $model=new IModel();
        $arr=array('name'=>$name);
        $model->setData($arr);
        $res=$model->update("id=$id");
        if($res){
            $this->redirect("show");
        }
    }
    public function del(){
        $id=IFilter::act(IReq::get("id"),'int');
        $model=new IModel();
        $res=$model->del("id=$id");
        if($res){
            $this->redirect("show");
        }
    }
}